package com.lxw.nonghe.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@TableName("t_operation_log")
@ApiModel(value = "OperationLog对象", description = "操作日志表")
public class OperationLog implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("日志ID")
    @TableId(type = IdType.AUTO)
    private Integer logId;

    @ApiModelProperty("操作用户ID")
    private Integer userId;

    @ApiModelProperty("操作用户名")
    private String username;

    @ApiModelProperty("操作模块")
    private String module;

    @ApiModelProperty("操作内容")
    private String operation;

    @ApiModelProperty("操作状态（成功/失败）")
    private String status;

    @ApiModelProperty("错误消息")
    private String errorMsg;

    @ApiModelProperty("操作时间")
    private Date operationTime;

    @ApiModelProperty("格式化后的操作时间")
    @TableField(exist = false)
    private String formattedOperationTime;

    // 新增格式化方法
    public String getFormattedOperationTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(operationTime);
    }

    public void setFormattedOperationTime(String formattedOperationTime) {
        this.formattedOperationTime = formattedOperationTime;
    }
}
